<?php
/**
 * Export CT_RaidTracker Event Triggers
 *
 * @category Plugins
 * @package CT_RaidTrackerImport
 * @copyright (c) 2006, EQdkp <http://www.edqkp.com>
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 * @author Garrett Hunter <loganfive@blacktower.com>
 * $Rev: 84 $ $Date: 2007-04-22 09:42:16 +0000 (Sun, 22 Apr 2007) $
 */

if ( !defined('EQDKP_INC') )
{
    die('Hacking attempt');
}

/**
 * This class exports event triggers
 * @subpackage ManageCTRT
 */
class CTRT_ExportEventTriggers extends CTRT_ManageEventTriggers {

	var $_myMode = "export";

    function CTRT_ExportEventTriggers()
    {
        global $db, $eqdkp, $user, $tpl, $pm;
        global $SID;

        parent::eqdkp_admin();

        $this->assoc_buttons(array(
            'form' => array(
                'name'    => '',
                'process' => 'display_form',
                'check'   => 'a_members_man'))
        );
    }

    /**
     * Display form
     */
    function display_form()
    {
        global $db, $eqdkp, $user, $tpl, $pm;
        global $SID;

		include_once("admin/ctrt_xml.php");
		$parser = new CTRT_XML();

		$daoEventTrigger = new CTRT_EventTrigger();
		$eventTriggers = $daoEventTrigger->getAll();
		
		$eventTrigger = array();
        foreach ( $eventTriggers as $trigger)
        {
			$eventTrigger[] = array("trigger"=>$trigger["event_trigger_name"],"result"=>$trigger["event_trigger_result"]);
        }
		
		$exportXML = $parser->xml_export(array("EventTriggers"=>array("EventTrigger"=>$eventTrigger)));

//ONE TIME EXTRACT OF CTRT CRAP
//		$ets = array();
//		foreach ($ctrt_settings['RaidNoteTriggers'] as $trigger=>$result) {
//			$et['trigger'] = $trigger;
//			$et['result'] = $result;
//		
//			$ets[] = $et;
//		}
//		$exportXML = $parser->xml_export(array("RaidNoteTriggers"=>array("RaidNoteTrigger"=>$ets)));
//
		$this->createMenus();
		
        $tpl->assign_vars(array(
            // Form values
            'EXPORT'          	=> htmlentities($exportXML),

            // Language
			'L_PLUGIN_TITLE'	=> $user->lang['ctrt'],

            /**
             * Help text
             */
            'L_HELP' 			=> $user->lang['ctrt_help_export'],

        ));

        $eqdkp->set_vars(array(
            'page_title'    => sprintf($user->lang['admin_title_prefix'], $eqdkp->config['guildtag'], $eqdkp->config['dkp_name']).': '.$user->lang['ctrt_adminmenu_title'].": ".$user->lang['ctrt_adminmenu_'.$this->getMyParam()."_".$this->getMyMode()],
            'template_path' => $pm->get_data('ctrt', 'template_path'),
            'template_file' => 'admin/export.html',
            'display'       => true)
        );
    }
}
?>
